package com.pf.controller;

import com.pf.dto.AddUserReq;
import com.pf.mapper.entity.User;
import com.pf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/add")
    public String addUser(@RequestBody AddUserReq req) {
        userService.insertUser(req);
        return "success";
    }

    @GetMapping("/getAll")
    public List<User> getAllUser() {
        return userService.getAllUser();
    }

    @GetMapping("/getUserByMobile")
    public User getUserByMobile(@RequestParam("mobile") String mobile) {
        return userService.getUserByMobile(mobile);
    }
}
